import { useMemo } from 'react'
import { useSelector } from 'react-redux'
import Admin from './Admin'
import Editor from './Editor'
import './style.scss'

// 不同角色的工作台
const d = {
  admin: Admin,
  editor: Editor
}

export default () => {
  const { userinfo } = useSelector(state => state.user)

  const role = useMemo(() => {
    if (userinfo.roles) {
      // console.log('---role', userinfo.roles[0])
      return userinfo.roles[0]
    }
    return ''
  }, [userinfo])

  const Role = role ? d[role] : () => null

  return <Role />
}